package ch9.thread4;

public class Account {
	private String name;
	private double money;

	public Account(String name, double money) {
		super();
		this.name = name;
		this.money = money;
	}

	// 取钱,保证余额不是负数
	public double withDraw(double m) {
		money -= m;
		return m;
		// if (money >= m) {
		// try {
		// Thread.sleep((long) (50 * Math.random()));
		// } catch (InterruptedException e) {
		// // TODO 自动生成的 catch 块
		// e.printStackTrace();
		// }
		// money -= m;
		// return m;
		// }
		// return 0;
	}

	public void deposit(double m) {
		money += m;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}
}
